import { createStore } from 'vuex'
// 菜单
import menu from './module/menu/index'
// 角色
import role from './module/role/index'
// 管理员
import admin from './module/admin/index'
export default createStore({
  state: {
    // userinfo:[]
    userinfo: sessionStorage.getItem('userinfo') ? JSON.parse(sessionStorage.getItem('userinfo') || '') : null
  },
  getters: {
    getUserInfo(state) {
      return state.userinfo
    }
  },
  mutations: {
    USER_LOGIN(state, payload) {
      if(payload){
        state.userinfo = payload
      sessionStorage.setItem('userinfo', JSON.stringify(payload))
      } else {
        sessionStorage.removeItem('userinfo')
      }
      
    }
  },
  actions: {
  },
  modules: {
    menu,
    role,
    admin
  }
})
